<template>
  <div class="app-container">
    <el-tabs type="border-card" @tab-click="changeTab">
      <el-tab-pane label="收件箱">
        <ReceiveTable ref="ReceiveTable" @showMsg="showMsg"/>
      </el-tab-pane>
      <el-tab-pane label="发件箱">
        <SendTable ref="SendTable" @showMsg="showMsg"/>
      </el-tab-pane>
    </el-tabs>
    <el-dialog title="消息详情" :visible.sync="view.show" destroy-on-close :append-to-body="true" :close-on-click-modal="false" width="800px">
      <el-form label-width="100px">
        <el-form-item label="标题：" prop="title">
          <span>{{ view.form.title }}</span>
        </el-form-item>
        <el-form-item label="接收人：" prop="duplicates">
          <el-tag
            v-for="(o,i) in view.form.detailQueryList"
            :key="i"
            type="warning"
            class="inline-block m5"
          >{{ o.userName }}{{ o.receiveType===2 ? '(抄送)' : '' }}</el-tag>
        </el-form-item>
        <el-form-item label="" label-width="0" prop="content">
          <div style="max-height: 300px;overflow-y: auto">
            <Editor v-if="view.show" id="viewEditorSend" :value="view.form.content" :minHeight="150" :readOnly="true"/>
          </div>
        </el-form-item>
        <el-form-item label="附件：" prop="attachInfoList" v-if="view.form.attachInfoList!=null && view.form.attachInfoList.length> 0">
          <el-row v-for="(o,i) in view.form.attachInfoList" :key="i">
            <a class="main-color point" @click="downloadFile(o)">{{ o.fileName }}</a>
          </el-row>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="view.show = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>

</template>

<script>

import ZlTable from '@/components/table/table-con'
import ReceiveTable from './messageReceive'
import SendTable from './messageSend'
export default {
  name: 'Message',
  components: { ZlTable,ReceiveTable,SendTable },
  data() {
    return {
      view: {
        show: false,
        form: {
          title:'',content:'',level:0,timer:0,type:0,detailQueryList:[],attachInfoList:[]
        }
      },
    }
  },
  computed: {

  },
  mounted() {

  },
  methods: {
    downloadFile(row){
      this.download('/sys/attach/download',{id:row.attachId},row.fileName)
    },
    showMsg(row) {
      this.view.form = this.$util.copy(row)
      this.view.show = true
    },
    changeTab(v) {
      if(v.index == 0){
        this.$refs.ReceiveTable.refreshLayout()
      }else if(v.index == 1){
        this.$refs.SendTable.refreshLayout()
      }

    }
  }
}
</script>
<style scoped>

</style>
